#include"BlockQueue.hpp"

zgw::BlockQueue<int> bq;

void* get(void*argv)
{
    sleep(2);
    int data;
    while(1)
    {
        bq.Get(&data);
        sleep(1);
        cout<<"获得数据:"<<data<<endl;
    }
    return nullptr;
}

void* set(void*argv)
{
    int data=1;
    while (1)
    {
        cout<<"写入数据:"<<data;
        bq.Push(data);
        data++;
        sleep(1);
    }
    
    return nullptr;
}


int main()
{

    pthread_t t1,t2;
    pthread_create(&t1,nullptr,get,nullptr);
    pthread_create(&t2,nullptr,set,nullptr);

    cout<<"创建线程成功"<<endl;
    pthread_join(t1,nullptr);
    pthread_join(t2,nullptr);

    return 0;
}